function negLL = ptm6(params,wdata)
% params(1): lottery weighting for buyer
% params(2): decisiveness
% 0: response bias for buyer
% params(3): lottery weighting for seller
% 0: response bias for seller
% params(4): fixed utility for buyer
% params(5): fixed utility for seller

priceutil = wdata.Price;
lotteryutil = (wdata.Role==1).* (0.5.*params(1).*wdata.Lottery) + ...
              (wdata.Role==2).* (0.5.*params(3).*wdata.Lottery);
pending = (wdata.Role==1).*((0>=0).*((1-0)./(1+exp(-params(2)*(lotteryutil-priceutil) + params(4)))+ 0) + (1-(0>=0)).*(1+0)./(1+exp(-params(2)*(lotteryutil-priceutil) + params(4)))) + ...
          (wdata.Role==2).*((0>=0).*((1-0)./(1+exp(-params(2)*(lotteryutil-priceutil) + params(5)))+ 0) + (1-(0>=0)).*(1+0)./(1+exp(-params(2)*(lotteryutil-priceutil) + params(5)))) ;
% pending(pending==0) = eps; 
negLL = - sum( wdata.Ending.*log(pending) + (1-wdata.Ending).*log(1-pending) );

end